package Test;

public class TryCatchDemo {
    public static void main(String[] args) {
        System.out.println("开始...");

        try {
            String str = null;
            System.out.println(str.length());
            //String str = "abc";
            //System.out.println(str.charAt(5));
        } catch (NullPointerException | StringIndexOutOfBoundsException e) {
            System.out.println("空指针或者下标越界异常，并且用相同的方式处理完毕了");
        } catch (Exception e) {
            System.out.println("反正出错");
        }

        System.out.println("结束...");
       /* System.out.println("开始...");

        try{
            String str = null;
            System.out.println(str.length());
            //String str = "abc";
            //System.out.println(str.charAt(5));
        }catch(NullPointerException|StringIndexOutOfBoundsException e){
            System.out.println("空指针或者下标越界异常，并且用相同的方式处理完毕了");
        }catch(Exception e){
            System.out.println("反正出错");
        }

        System.out.println("结束...");*/
    }
}
